package com.minli.weixin.common.util;

import com.alibaba.fastjson.JSON;

public class BsStringUtil {
	//private static Logger logger = LoggerFactory.getLogger(DateUtil.class);

    /**
     * 掩码工具
     * beginNum 开头几位不模糊数
     * endNum 倒数第几个不模糊
     * return String
     */
    public static String maskCode(String str,int beginNum,int endNum){
    	if(str != null && str.length() > beginNum && str.length() > endNum){
    		String b = str.substring(0,beginNum);
    		String e = str.substring(str.length()-endNum,str.length());
    		String mask = "";
    		for(int i=0;i<(str.length()-beginNum-endNum);i++){
    			mask +="*";
    		}
    		return b+mask+e;
    	}
    	return str;
    }
    
    public static boolean isJson(String str){
    	boolean flag = false;
    	try{
    		JSON.parseObject(str);
    		flag = true;
    	}catch(Exception e){
    		flag = false;
    	}
    	return flag;
    }
    
/*    public static void main(String[] args) {
		System.out.println(isJson("{2}"));
	}*/
    
}
